package h.ku.lang
{
	import h.ku.eval.Args;

	public class hkuBlockNative extends hkuObject
	{
		public var src:Function
		
		public function hkuBlockNative(f:Function)
		{
			setType("Block")
			setType("BlockNative")
			
			this.src = f
			
			this.addAS3Function(":",function(a:Args):void
			{
				a.caller.finishFunctionEval(src.call(null,a))
			})
			this.addAS3Function("call",function(a:Args):void
			{
				a.caller.finishFunctionEval(src.call(null,a))
			})
			this.addAS3Function("apply",function(a:Args):void
			{
				a.caller.finishFunctionEval(apply(a))
			})
		}
		
		public function call(a:Args):*
		{
			return src.call(null,a)
		}
		
		public function apply(a:Args):*
		{
			return src.call(null,new Args(a.caller,a.arguments[0] || [],a.callingObject))
		}
	

	}
}